package org.fan;

import java.util.ArrayList;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFRow;


public class ExcelDataVO {
	
	static String COLUMNNAMETILE = "COLUMNNAME";
	static String COLUMNVALUETILE = "INFO";
	
	String columnName;
	List<Object> columnValueArray;
	
	public ExcelDataVO(){
	}
	
	public ExcelDataVO(String columnName, List<Object> columnValueArray) {
		super();
		this.columnName = columnName;
		this.columnValueArray = columnValueArray;
	}
    /**
     * 获取列名称所在excel的列数，从0开始
     * @return  返回-1表示没找到
     */
	public static int getColumnNameIndex(HSSFRow row){
		int flag = 0;
		while(row.getCell(flag)!=null){
			if(row.getCell(flag).toString().toUpperCase().equals(ExcelDataVO.COLUMNNAMETILE)){
				return flag;
			}
			flag++;
			//100列内如果找不到，返回-1；
			if(flag>100){
				return -1;
			}
		}
		return -1;
	}

    /**
     * 获取列名称所在excel的列数，从0开始
     * @return
     */
	public static List<Integer>  getColumnValueIndexs(HSSFRow row){
		int flag = 0;
		List<Integer>  returnFlagArray = new ArrayList<Integer>();
		while(row.getCell(flag)!=null){
			if(row.getCell(flag).toString().toUpperCase().equals(ExcelDataVO.COLUMNVALUETILE)){
				returnFlagArray.add(new Integer(flag));
			}
			flag++;
			//最多找100列
			if(flag>100){
				return returnFlagArray;
			}
		}
		return returnFlagArray;
	}
	
	public String getColumnName() {
		return columnName;
	}
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public List<Object> getColumnValueArray() {
		return columnValueArray;
	}

	public void setColumnValueArray(List<Object> columnValueArray) {
		this.columnValueArray = columnValueArray;
	}
	
}
